package com.fox.imagedb;

import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import com.fox.imagedb.gui.MainPanel;
import com.fox.imagedb.gui.menu.ImageDBMenuBar;

public class ImageDB {

	/**
	 * Create the GUI and show it. For thread safety, this method should be
	 * invoked from the event-dispatching thread.
	 */
	private static void createAndShowGUI() {

		setUILookAndFeel();

		// Create and set up the window.
		JFrame frame = new JFrame("Fox Team Image Analyzer v0.1");
		frame.setLayout(new GridBagLayout());
		frame.setExtendedState(Frame.MAXIMIZED_BOTH);

		GridBagConstraints c = new GridBagConstraints();
		c.fill = GridBagConstraints.BOTH;

		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		// Set the main panel
		MainPanel mainPanel = new MainPanel();
		mainPanel.setOpaque(true); // content panes must be opaque

		frame.setContentPane(mainPanel);
		
		// Set the menu bar
		frame.setJMenuBar(new ImageDBMenuBar(mainPanel));

		// Display the window.
		frame.pack();
		frame.setVisible(true);
	}

	private static void setUILookAndFeel() {
		try {
			// Set System L&F
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (UnsupportedLookAndFeelException e) {
			// handle exception
		} catch (ClassNotFoundException e) {
			// handle exception
		} catch (InstantiationException e) {
			// handle exception
		} catch (IllegalAccessException e) {
			// handle exception
		}
	}

	public static void main(String[] args) {
		// Schedule a job for the event-dispatching thread:
		// creating and showing this application's GUI.
		javax.swing.SwingUtilities.invokeLater(new Runnable() {

			public void run() {
				createAndShowGUI();
			}
		});
	}
}
